﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using UnityEditor.Scripting.Compilers;

internal class MxmlcHelper
{
    internal static string AllSourcePaths(FlashFileHelper fileHelper)
    {
        string[] first = new string[] { fileHelper.PathForAs3Src(), fileHelper.PathForConvertedDotNetCode(), fileHelper.PathForUserBuildAs3() };
        return FormatSourcePathsForCmdline(first.Concat<string>(fileHelper.FindUserSourcePaths()));
    }

    private static string FormatSourcePathsForCmdline(IEnumerable<string> paths)
    {
        StringBuilder builder = new StringBuilder();
        bool flag = true;
        IEnumerator<string> enumerator = paths.GetEnumerator();
        try
        {
            while (enumerator.MoveNext())
            {
                string current = enumerator.Current;
                if (!flag)
                {
                    builder.Append(" ");
                }
                builder.Append("-source-path=");
                builder.Append(CommandLineFormatter.PrepareFileName(current));
                flag = false;
            }
        }
        finally
        {
            if (enumerator == null)
            {
            }
            enumerator.Dispose();
        }
        return builder.ToString();
    }

    internal static string[] MxmlcArgumentsFor(FlashPostProcessSettings settings, FlashFileHelper fileHelper)
    {
        <MxmlcArgumentsFor>c__AnonStorey34 storey = new <MxmlcArgumentsFor>c__AnonStorey34 {
            fileHelper = fileHelper
        };
        string str = Enumerable.Aggregate<string, string>(storey.fileHelper.FindUserSwcs(), string.Empty, new Func<string, string, string>(storey.<>m__51));
        string str2 = "-debug=" + (!settings.IsDevelopment ? "false" : "true");
        string str3 = "-optimize=" + (!settings.IsDevelopment ? "true" : "false");
        object[] objArray1 = new object[] { "-default-size ", settings.Width, " ", settings.Height };
        string str4 = string.Concat(objArray1);
        return new string[] { 
            "-Xmx768m -Dsun.io.useCanonCaches=false -Duser.region=US -Duser.language=en", ("-jar " + storey.fileHelper.PathForMxmlc()), ("+flexlib=" + storey.fileHelper.PathForFlexFrameworks()), storey.fileHelper.PathForUnityAppDotAs(), str2, str3, ("-include-libraries=" + storey.fileHelper.FullPathForUnityNativeSwc(settings.GetUnityNativeSwcForSubTarget(settings.StripPhysics))), str, AllSourcePaths(storey.fileHelper), "-static-link-runtime-shared-libraries=true", ("-swf-version=" + settings.GetSwfVersionForPlayerVersion()), str4, "-omit-trace-statements=false", "-default-script-limits=1000,60", ("-target-player=" + settings.GetTargetPlayerForSubtarget()), "-verbose-stacktraces=true", 
            "-compress=false", settings.MxmlcCompileTimeConstants(), ("-output=" + storey.fileHelper.PathForTempSwf())
         };
    }

    [CompilerGenerated]
    private sealed class <MxmlcArgumentsFor>c__AnonStorey34
    {
        internal FlashFileHelper fileHelper;

        internal string <>m__51(string current, string includeLib)
        {
            return (current + " -include-libraries=" + this.fileHelper.PrepareFileName(includeLib));
        }
    }
}

